package com.xhwl.data.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xhwl.common.dto.cent.sdata.EnterpriseDTO;
import com.xhwl.common.pojo.AbstractAccount;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.pojo.cent.sdata.Enterprise;
import com.xhwl.common.query.cent.sdata.EnterpriseQuery;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description: 企业管理
 * @author: lianghz
 * @create: 2020-11-25
 **/
@RestController
public interface IEnterpriseService extends IService<Enterprise> {

    /**
     * 创建企业
     *
     * @param enterpriseDTO
     * @param permissions
     * @param account
     * @return
     */
    @RequestMapping(value = "/enterprise-service/create", method = RequestMethod.POST)
    ResultJson<Integer> create(@RequestPart EnterpriseDTO enterpriseDTO, @RequestPart List<Integer> permissions, @RequestPart(required = false) Account account);

    /**
     * 删除企业（逻辑删除）
     *
     * @param id
     * @param account
     * @return
     */
    @RequestMapping(value = "/enterprise-service/delete", method = RequestMethod.POST)
    ResultJson delete(@RequestPart Integer id, @RequestPart Account account);

    /**
     * 更新企业
     *
     * @param enterpriseDTO
     * @param permissions
     * @param account
     * @return
     */
    @RequestMapping(value = "/enterprise-service/update", method = RequestMethod.POST)
    ResultJson update(@RequestPart EnterpriseDTO enterpriseDTO, @RequestPart List<Integer> permissions, @RequestPart(required = false) AbstractAccount account);

    /**
     * 更新企业logo
     *
     * @param id
     * @param logo
     * @return
     */
    @RequestMapping(value = "/enterprise-service/update-logo", method = RequestMethod.POST)
    ResultJson updateLogo(@RequestPart Integer id, @RequestPart String logo);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/enterprise-service/find-by-id", method = RequestMethod.POST)
    Enterprise findById(@RequestPart Integer id);

    /**
     * 分页查询
     *
     * @param enterpriseQuery
     * @param page
     * @param account
     * @return
     */
    @RequestMapping(value = "/enterprise-service/query-page", method = RequestMethod.POST)
    Page<Enterprise> page(@RequestPart(required = false) EnterpriseQuery enterpriseQuery, @RequestPart Page page, @RequestPart(required = false) Account account);

    /**
     * 单个查询
     *
     * @param enterpriseQuery
     * @param account
     * @return
     */
    @RequestMapping(value = "/enterprise-service/find", method = RequestMethod.POST)
    Enterprise find(@RequestPart(required = false) EnterpriseQuery enterpriseQuery, @RequestPart(required = false) Account account);

    /**
     * 查询企业列表
     *
     * @param enterpriseQuery
     * @return
     */
    @RequestMapping(value = "/enterprise-service/list", method = RequestMethod.POST)
    List<Enterprise> list(@RequestPart(required = false) EnterpriseQuery enterpriseQuery, @RequestPart(required = false) Account account);


    /**
     * 查询企业列表 无账号限制
     *
     * @param enterpriseQuery
     * @return
     */
    @RequestMapping(value = "/enterprise-service/list-by-query", method = RequestMethod.POST)
    List<Enterprise> list(@RequestPart(required = false) EnterpriseQuery enterpriseQuery);


    /**
     * 查询企业列表、填充入驻空间等信息
     *
     * @param enterpriseQuery
     * @return
     */
    @RequestMapping(value = "/enterprise-service/list-detail", method = RequestMethod.POST)
    List<EnterpriseDTO> listDetail(@RequestPart(required = false) EnterpriseQuery enterpriseQuery, @RequestPart(required = false) Account account);


    /**
     * 设置企业是否禁用
     *
     * @param id
     * @param isBan
     * @return
     */
    @PostMapping(value = "/enterprise-service/ban")
    ResultJson setBan(@RequestPart AbstractAccount account, @RequestPart Integer id, @RequestPart Boolean isBan);

    /**
     * 根据帐号查询企业
     *
     * @param operateAccount
     * @return
     */
    @GetMapping(value = "/enterprise-service/find-byaccount")
    List<Enterprise> findByAccount(@RequestPart Account operateAccount);

    /**
     * 根据企业ID查询其下入驻商或服务商
     * @param enterpriseId
     * @param types
     * @return
     */
    @PostMapping("/enterprise-service/list-by-type")
    List<Enterprise> listById(@RequestPart Integer enterpriseId, @RequestPart List<Integer> types);

    /**
     * 查询入住企业对应员工数
     *
     * @param enterpriseId
     * @return
     */
    @RequestMapping(value = "/enterprise-service/count-residentEnterprise", method = RequestMethod.POST)
    Map countResidentEntStaffs(@RequestPart Integer enterpriseId);

    ResultJson tree(Integer enterpriseId, List<Integer> types);

    /**
     * 获取企业详情，包括企业管理员信息
     * @param enterpriseQuery
     * @return
     */
    @RequestMapping(value = "/enterprise-service/get-detail", method = RequestMethod.POST)
    EnterpriseDTO getDetail(@RequestPart(required = false) EnterpriseQuery enterpriseQuery);

    /**
     * 根据帐号获取企业
     * @param id
     * @param account
     * @return
     */
    Enterprise getOne(Integer id, Account account);

    /**
     * 运管平台删除企业
     * @param id
     * @param account
     * @return
     */
    ResultJson deleteAdmin(Integer id, Account account);

    /**
     * 是否是运营商
     * @param enterpriseId
     * @return
     */
    Boolean isOperator(Integer enterpriseId);

    /**
     * 根据企业类型统计企业数量
     * @param types
     * @return
     */
    @RequestMapping(value = "/enterprise-service/statistics-by-type", method = RequestMethod.POST)
    Map<String, Integer> statisticsEnt(@RequestPart List<Integer> types);

    /**
     * 查询企业管理员
     *
     * @param enterpriseIds
     * @return
     */
    Map<Integer, Account> findEnterpriseAdmin(List<Integer> enterpriseIds);

    /**
     * 企业管理--统计楼层下所有【经营品类】的企业
     *
     * @param floorOrgId
     * @return
     */
    @RequestMapping(value = "/enterprise-service/find-category-by-floor", method = RequestMethod.POST)
    List countCatrgoryByFloorOrg(@RequestPart("floorOrgId") Integer floorOrgId);
    /**
     * 获取企业下员工数量、过滤无效数据
     * @param entIds
     * @return
     */
    Map<Integer, Integer> getStaffCount(List<Integer> entIds);

    /**
     * 获得所有企业列表
     */
    @RequestMapping(value = "/enterprise-service/getAll", method = RequestMethod.POST)
    List<Enterprise> getAll();

    /**
     * 查入驻企业
     */
    @RequestMapping(value = "/enterprise-service/findEntByOrgids", method = RequestMethod.POST)
    List<Enterprise> findEntByOrgids(@RequestPart List<Integer> orgIds);

    /**
     * 通过账号id查询企业
     */
    @RequestMapping(value = "/enterprise-service/getEntListByAccountId", method = RequestMethod.POST)
    List<Enterprise> getEntListByAccountId(@RequestPart("accountId") Integer accountId);

}
